* Project      :  The Full, Persistent, and Symmetric Pass-Through of a Temporary VAT Cut
* Authors      :  Márcia Silva-Pereira, João Quelhas, Tiago Bernardino, Ricardo Duque Gabriel
* Date         :  01/04/2025
* Description  :  Event-study Regression - Vegetable Oils
* Dependencies :
* Modifications: (add date, author and change)

*********************************************************
*                Event-study Regression                 *
*********************************************************

local vce_cluster ${vce_cluster}
local weights ${weights}
local variable ${variable}
local aggregation ${aggregation}
	
// Load the cleaned dataset.
use "${path_work}/auxiliar/imputation_0_oils.dta", clear

collapse (${aggregation}) ${variable} (first) ecoicop5 treatment weight, by (id_sm five_day_number)

// Compute a price index with base in the day before policy announcement I.
local   base_date 22
egen    base_price_23032023 = total(${variable}/ (five_day_number == `base_date')), by(id_sm)
gen     index_23032023 = (${variable}/ base_price_23032023) * 100

xtset id_sm five_day_number

*********************************************************

* FIGURE A.8: Pass-Through Estimates of a Temporary VAT Cut in Portugal for Vegetable Oils (A) Policy Implementation
*********************************************************

preserve

// Keep the data around the event.
keep if five_day_number >= 17
keep if five_day_number <= 32

// Policy variable: 1 after the reference date.
replace treatment = 0 if five_day_number < 23

// Run the event-study regression.
xtevent index_23032023, policyvar(treatment) panelvar(id_sm) timevar(five_day_number) window(${window_low} ${window_high}) vce(cluster ${vce_cluster}) impute(nuchange) reghdfe trend(${trend}, method(gmm) saveoverlay)
	
// Make the plot with the results.
xteventplot, ytitle("Percentage change") xtitle("5-day Periods to Event") ///
	nosupt scatterplotopts(lcolor(dknavy) recast(connected) mcolor(dknavy) ///
	msymbol(circle)) ciplotopts(recast(rarea) mcolor(black) fcolor(dknavy*0.2)) ///
	graphregion(fcolor(white)) yscale(lcolor(black) lwidth(none) line) ///
	tscale(lcolor(black) lwidth(none) line) ylabel(-30(5)10) ///
	yline(-18.69, lcolor("dknavy") lpattern(dash) lwidth(medthin)) ///
	text(-20 -4.8 "100% Pass-Through", color("dknavy") placement(e)) ///
	xline(0, lcolor("gray*0.5") lpattern(solid) lwidth(medthin)) ///
	text(-29.5 0.1 "Announcement", color("gray") placement(e)) ///
	xline(5, lcolor("gray*0.5") lpattern(solid) lwidth(medthin)) ///
	text(-29.5 5.1 "Implementation", color("gray") placement(e))
		
// Export the graph.
graph export "${results_figures}/figure_a8a.png", as(png) replace width(2400) height(1372)

restore

*********************************************************


* FIGURE A.8: Pass-Through Estimates of a Temporary VAT Cut in Portugal for Vegetable Oils (B) Policy Reversal
*********************************************************

preserve

// Keep the data around the event.
keep if five_day_number >= 61
keep if five_day_number <= 83

// Policy variable: 1 after the reference date.
replace treatment = 0 if five_day_number < 66

// Run the event-study regression.
xtevent index_23032023, policyvar(treatment) panelvar(id_sm) timevar(five_day_number) window(${window_low} 16) vce(cluster ${vce_cluster}) impute(nuchange) reghdfe trend(${trend}, method(gmm) saveoverlay)
	
// Make the plot with the results.
xteventplot, ytitle("Percentage change") xtitle("5-day Periods to Event") ///
	nosupt scatterplotopts(lcolor(dknavy) recast(connected) mcolor(dknavy) ///
	msymbol(circle)) ciplotopts(recast(rarea) mcolor(black) fcolor(dknavy*0.2)) ///
	graphregion(fcolor(white)) yscale(lcolor(black) lwidth(none) line) ///
	tscale(lcolor(black) lwidth(none) line) ylabel(-5(5)30) ///
	yline(13, lcolor("dknavy") lpattern(dash) lwidth(medthin)) ///
	text(14.5 -5.2 "100% Pass-Through", color("dknavy") placement(e)) ///
	xline(0, lcolor("gray*0.5") lpattern(solid) lwidth(medthin)) ///
	text(29 0.1 "Announcement", color("gray") placement(e)) ///
	xline(14, lcolor("gray*0.5") lpattern(solid) lwidth(medthin)) ///
	text(29 11.8 "Reversal", color("gray") placement(e))

// Export the graph.
graph export "${results_figures}/figure_a8b.png", as(png) replace width(2400) height(1372)

restore

*********************************************************

erase "${path_work}/auxiliar/imputation_0_oils.dta"

*********************************************************
